package com.shop2cn.iapi.coupon.testcase;

import java.util.ArrayList;
import java.util.List;

import org.junit.After;
import org.junit.AfterClass;
import org.junit.Before;
import org.junit.BeforeClass;
import org.junit.Ignore;
import org.junit.Test;
import org.junit.experimental.categories.Category;

import com.shop2cn.iapi.coupon.parameter.UseCouponBean;
import com.shop2cn.iapi.coupon.service.UseCouponCall;
import com.shop2cn.iapi.coupon.service.UserReceiveCouponCall;
import com.shop2cn.iapi.couponmanage.parameter.CreateCouponBean;
import com.shop2cn.iapi.couponmanage.parameter.SellerCreateBatchBean;
import com.shop2cn.iapi.couponmanage.service.CreateCouponCall;
import com.shop2cn.iapi.couponmanage.service.SellerCreateBatchCall;
import com.ymt.core.tool.Logger;
import com.ymt.utils.annotation.*;
import com.ymt.utils.tag.*;
import com.ymttest.business.service.CouponShop2cnMCallService;
import com.ymttest.database.model.CouponShop2cn.coupon;
import com.ymttest.database.model.CouponShop2cn.couponbatch;
import com.ymttest.database.sqlwapper.CouponShop2cn.couponWapper;
import com.ymttest.database.sqlwapper.CouponShop2cn.couponbatchWapper;
import com.ymttest.utils.TestDataManager;
/**
*用券
*FreeMaker Template自动生成代码
*<!--添加使用记录-->
	insert into ymt_CouponTradeRecord (OrderId, UserId, CouponCode, BatchId, TradeType)
	values (#{orderId,jdbcType=INTEGER},
	#{userId,jdbcType=INTEGER},
	#{couponCode,jdbcType=VARCHAR},
	#{batchId,jdbcType=INTEGER},
	#{tradeType,jdbcType=TINYINT})

		<!--扣减用户优惠券使用剩余次数-->
        UPDATE a SET iCouponUsedCount=iCouponUsedCount-1 from Ymt_CouponPrivateUserBound a with (index  = IX_Ymt_CouponPrivateUserBound_sCouponCode)
        WHERE sCouponCode=#{couponCode, jdbcType=VARCHAR}
        AND iUserId=#{userId, jdbcType=INTEGER}
        AND iCouponUsedCount > 0
        if(@@ROWCOUNT = 0)
        begin
            select 1
            return
        end

		<!--如果是虚拟券则要更新其使用状态-->
        if(exists(select null from Ymt_CouponVirtualRelation with(nolock) where CouponCode = #{couponCode,jdbcType=VARCHAR}))
        begin
            update Ymt_CouponVirtualRelation set IsUsed = 1 where CouponCode = #{couponCode,jdbcType=VARCHAR}
        end

        select 0

        <!--更新批次剩余使用次数（由于setting是公共资源，放到事物外执行）
        UPDATE Ymt_CouponSetting SET iMaxUseTime=iMaxUseTime-1
        WHERE iCouponSettingId IN (SELECT iCouponSettingId FROM Ymt_CouponBatch WITH(NOLOCK) WHERE ibatchid=#{batchId, jdbcType=INTEGER})-->
*/
@TestSuite
public class Ts_UseCoupon{ 
	private static UseCouponBean usecouponBean;
	private static UseCouponCall usecouponCall;
	@BeforeClass
	public static void setUp() {
		Logger.createResultFile("用券");
	}

	@Before
	public void caseUp() {
		usecouponBean=new UseCouponBean();
		usecouponCall=new UseCouponCall();
	}

	@AfterClass
	public static void tearDown() {
		Logger.generateResult(usecouponCall.getOpurl());
	}

	@After
	public void caseDown() {
		Logger.end();
	}
	@Test
	@Category({P1.class})
	@TestCase
	//@Ignore
	public void Tc_UseCoupon_001() {
		Logger.start(true,"用券-平台券-领取券");
		try {
			
			int userId = TestDataManager.getRandomIntNum(8);
			int orderId = TestDataManager.getRandomIntNum(10);
			CouponShop2cnMCallService CouponShop2cnMCallService = new CouponShop2cnMCallService();
			CreateCouponBean createCouponBean = CouponShop2cnMCallService.setDefaultPlatformCreateCouponBeanForRecieve();
			CreateCouponCall createCouponCall= CouponShop2cnMCallService.createPlatformCoupon(createCouponBean);
			
			UserReceiveCouponCall userReceiveCouponCall = CouponShop2cnMCallService.receiveCouponInfo(createCouponCall.getBatchCode(), userId);

			List<String> CouponCodes=new ArrayList();
			CouponCodes.add(userReceiveCouponCall.getUserReceiveResult().getCouponCode());
			
			couponbatch batch1 = new couponbatchWapper().selectBybatchCode(createCouponCall.getBatchCode()).get(0);
			usecouponBean.setUserId(userId);
			usecouponBean.setMainOrderId(orderId);
			usecouponBean.setCouponCodes(CouponCodes);
			usecouponBean.setAppId("mansit");
			usecouponBean.setRequestId("12344566");
			
			usecouponCall.setData(usecouponBean);
			usecouponCall.callService();	
			
			//job处理
			//平台券异步JOB回调更新批次已领取和使用数量，放到Job,目前为了测试方便，直接调用
			new CouponShop2cnMCallService().updatereceivedandusedcount();
			
			Logger.verifyEquals("操作成功！", usecouponCall.getMessage(), "验证返回Message");
			Logger.verifyEquals("0", usecouponCall.getStatusCode1(), "验证返回StatusCode");

			Logger.verifyEquals("null", usecouponCall.getSellerId(), "验证返回sellerId");
			
			couponbatch batch2 = new couponbatchWapper().selectBybatchCode(createCouponCall.getBatchCode()).get(0);

			Logger.verifyEquals(1, batch2.getUsedCount()-batch1.getUsedCount(), "验证数据库couponbatch中UsedCount");
//			Logger.verifyEquals(1, batch1.getTotalNum()-batch2.getTotalNum(), "验证数据库couponbatch中iMaxUseTime");
			
			coupon coupon=new couponWapper().selectByBatchIdAndUserId(batch2.getBatchId(), usecouponBean.getUserId()).get(0);
			
			Logger.verifyEquals(true, coupon.getIsUsed(), "验证数据库coupon中IsUsed");
			for(int i=0;i<usecouponBean.getCouponCodes().size();i++){
			   Logger.verifyEquals(usecouponBean.getCouponCodes().get(i), coupon.getCouponCode(), "验证数据库coupon中第"+i+"条CouponCode");
			}
			Logger.verifyEquals(orderId, Integer.parseInt(coupon.getMainOrderId().toString()), "验证数据库coupon中MainOrderId");
		} catch (Exception e) {
			Logger.fail(e);
		}
	}
	
	@Test
	@Category({P1.class})
	@TestCase
	public void Tc_UseCoupon_002() {
		Logger.start(true,"用券-商家券");
		try {
			
			int userId = TestDataManager.getRandomIntNum(8);
			CouponShop2cnMCallService CouponShop2cnMCallService = new CouponShop2cnMCallService();
			
			SellerCreateBatchBean sellerCreateBatchBean = CouponShop2cnMCallService.setDefaultSellerCreateBatchBean();
			SellerCreateBatchCall createCouponCall= CouponShop2cnMCallService.SellerCreateBatch(sellerCreateBatchBean);
		
			UserReceiveCouponCall userReceiveCouponCall = CouponShop2cnMCallService.receiveCouponInfo(createCouponCall.getBatchCode(), userId);
			
			couponbatch batch1 = new couponbatchWapper().selectBybatchCode(createCouponCall.getBatchCode()).get(0);

			List<String> CouponCodes=new ArrayList();
			CouponCodes.add(userReceiveCouponCall.getUserReceiveResult().getCouponCode());
			
			usecouponBean.setUserId(userId);
			usecouponBean.setMainOrderId(12234);
			usecouponBean.setCouponCodes(CouponCodes);
			usecouponBean.setAppId("mansit");
			usecouponBean.setRequestId("12344566");
			
			usecouponCall.setData(usecouponBean);
			usecouponCall.callService();	
			//平台券异步JOB回调更新批次已领取和使用数量，放到Job,目前为了测试方便，直接调用
			new CouponShop2cnMCallService().updatereceivedandusedcount();
			
			Logger.verifyEquals("操作成功！", usecouponCall.getMessage(), "验证返回Message");
			Logger.verifyEquals("0", usecouponCall.getStatusCode1(), "验证返回StatusCode");

           Logger.verifyEquals("null", usecouponCall.getSellerId(), "验证返回sellerId");
			
			couponbatch batch2 = new couponbatchWapper().selectBybatchCode(createCouponCall.getBatchCode()).get(0);

			//job处理
			//Thread.sleep(6000);
			Logger.verifyEquals(1, batch2.getUsedCount()-batch1.getUsedCount(), "验证数据库couponbatch中UsedCount");
//			Logger.verifyEquals(1, batch1.getTotalNum()-batch2.getTotalNum(), "验证数据库couponbatch中iMaxUseTime");
			
			coupon coupon=new couponWapper().selectByBatchIdAndUserId(batch2.getBatchId(), usecouponBean.getUserId()).get(0);
			
			Logger.verifyEquals(true, coupon.getIsUsed(), "验证数据库coupon中IsUsed");
			for(int i=0;i<usecouponBean.getCouponCodes().size();i++){
			   Logger.verifyEquals(usecouponBean.getCouponCodes().get(i), coupon.getCouponCode(), "验证数据库coupon中第"+i+"条CouponCode");
			}
			Logger.verifyEquals(usecouponBean.getMainOrderId(), coupon.getMainOrderId(), "验证数据库coupon中MainOrderId");
			
		} catch (Exception e) {
			Logger.fail(e);
		}
	}
	
	@Test
	@Category({P1.class})
	@TestCase
	public void Tc_UseCoupon_003() {
		Logger.start(true,"用券-UserId空");
		try {
			
			int userId = TestDataManager.getRandomIntNum(8);
			CouponShop2cnMCallService CouponShop2cnMCallService = new CouponShop2cnMCallService();
			SellerCreateBatchBean sellerCreateBatchBean = CouponShop2cnMCallService.setDefaultSellerCreateBatchBean();
			SellerCreateBatchCall createCouponCall= CouponShop2cnMCallService.SellerCreateBatch(sellerCreateBatchBean);
			
			UserReceiveCouponCall userReceiveCouponCall = CouponShop2cnMCallService.receiveCouponInfo(createCouponCall.getBatchCode(), userId);
			
			List<String> CouponCodes=new ArrayList();
			CouponCodes.add(userReceiveCouponCall.getUserReceiveResult().getCouponCode());
			
			usecouponBean.setCouponCodes(CouponCodes);
			usecouponBean.setMainOrderId(12234);
			usecouponBean.setAppId("mansit");
			usecouponBean.setRequestId("12344566");
			
			usecouponCall.setData(usecouponBean);
			usecouponCall.callService();	
			
			Logger.verifyEquals("1", usecouponCall.getStatusCode1(), "验证返回StatusCode");
			Logger.verifyEquals("参数错误|userId:userId must", usecouponCall.getMessage(), "验证返回Message");

		} catch (Exception e) {
			Logger.fail(e);
		}
	}
	
	@Test
	@Category({P1.class})
	@TestCase
	public void Tc_UseCoupon_004() {
		Logger.start(true,"用券-OrderId空,默认0");
		try {
			
			int userId = TestDataManager.getRandomIntNum(8);
			CouponShop2cnMCallService CouponShop2cnMCallService = new CouponShop2cnMCallService();
			SellerCreateBatchBean sellerCreateBatchBean = CouponShop2cnMCallService.setDefaultSellerCreateBatchBean();
			SellerCreateBatchCall createCouponCall= CouponShop2cnMCallService.SellerCreateBatch(sellerCreateBatchBean);
			
			UserReceiveCouponCall userReceiveCouponCall = CouponShop2cnMCallService.receiveCouponInfo(createCouponCall.getBatchCode(), userId);
			
			List<String> CouponCodes=new ArrayList();
			CouponCodes.add(userReceiveCouponCall.getUserReceiveResult().getCouponCode());
			
			usecouponBean.setUserId(userId);
			usecouponBean.setCouponCodes(CouponCodes);
			usecouponBean.setAppId("mansit");
			usecouponBean.setRequestId("12344566");
			
			usecouponCall.setData(usecouponBean);
			usecouponCall.callService();	
			
			Logger.verifyEquals("1", usecouponCall.getStatusCode1(), "验证返回StatusCode");
			Logger.verifyEquals(true, usecouponCall.getMessage().contains("mainOrderId:mainOrderId must"), "验证返回Message");

		} catch (Exception e) {
			Logger.fail(e);
		}
	}
	
	@Test
	@Category({P1.class})
	@TestCase
	public void Tc_UseCoupon_005() {
		Logger.start(true,"用券-CouponCodes空");
		try {
			
			int userId = TestDataManager.getRandomIntNum(8);
			
			List<String> CouponCodes=new ArrayList();
			usecouponBean.setUserId(userId);
			usecouponBean.setCouponCodes(CouponCodes);
			usecouponBean.setMainOrderId(12234);
			usecouponBean.setAppId("mansit");
			usecouponBean.setRequestId("12344566");

			usecouponCall.setData(usecouponBean);
			usecouponCall.callService();	
			
			Logger.verifyEquals("1", usecouponCall.getStatusCode1(), "验证返回StatusCode");
			Logger.verifyEquals("参数错误|couponCodes:couponcodes must", usecouponCall.getMessage(), "验证返回Message");
			
		} catch (Exception e) {
			Logger.fail(e);
		}
	}
	
	@Test
	@Category({P1.class})
	@TestCase
	public void Tc_UseCoupon_006() {
		Logger.start(true,"用券-UserId与券码不匹配");
		try {
			
			int userId = TestDataManager.getRandomIntNum(8);
			CouponShop2cnMCallService CouponShop2cnMCallService = new CouponShop2cnMCallService();
			SellerCreateBatchBean sellerCreateBatchBean = CouponShop2cnMCallService.setDefaultSellerCreateBatchBean();
			SellerCreateBatchCall createCouponCall= CouponShop2cnMCallService.SellerCreateBatch(sellerCreateBatchBean);
			
			UserReceiveCouponCall userReceiveCouponCall = CouponShop2cnMCallService.receiveCouponInfo(createCouponCall.getBatchCode(), userId);
			
			List<String> CouponCodes=new ArrayList();
			CouponCodes.add(userReceiveCouponCall.getUserReceiveResult().getCouponCode());
			
			usecouponBean.setUserId(userId+1);
			usecouponBean.setMainOrderId(12234);
			usecouponBean.setCouponCodes(CouponCodes);
			usecouponBean.setAppId("mansit");
			usecouponBean.setRequestId("12344566");
			
			usecouponCall.setData(usecouponBean);
			usecouponCall.callService();	
			
			Logger.verifyEquals("21002", usecouponCall.getStatusCode1(), "验证返回StatusCode");

			Logger.verifyEquals("未找到符合条件的用户优惠券|优惠券不属于当前用户", usecouponCall.getMessage(), "验证返回StatusCode");
			
		} catch (Exception e) {
			Logger.fail(e);
		}
	}
	
	@Test
	@Category({P1.class})
	@TestCase
	@Ignore
	public void Tc_UseCoupon_007() {
		Logger.start(true,"用券-平台券-领取券");
		try {
//			
//			int orderId = TestDataManager.getRandomIntNum(10);
//
//			UseCouponInfo couponInfo = new UseCouponInfo();
//			couponInfo.setOrderId(orderId);
//			couponInfo.setCouponCode("1702215077111537CVHF7NI2");
//			
//			List<UseCouponInfo> useCouponInfos = new ArrayList<>();
//			useCouponInfos.add(couponInfo);
//			
//			usecouponBean.setUserId(111537);
//			usecouponBean.setUseCouponInfos(useCouponInfos);
//			usecouponBean.setAppId("mansit");
//			usecouponBean.setRequestId("12344566");
//			
//			usecouponCall.setData(usecouponBean);
//			usecouponCall.callService();	
//			
//			Logger.verifyEquals("操作成功！", usecouponCall.getMessage(), "验证返回Message");
//			Logger.verifyEquals("0", usecouponCall.getStatusCode1(), "验证返回StatusCode");
//
//			Logger.verifyEquals("null", usecouponCall.getSellerId(), "验证返回StatusCode");
		
			
		} catch (Exception e) {
			Logger.fail(e);
		}
	}
	
	
	@Test
	@Category({P1.class})
	@TestCase
	public void Tc_UseCoupon_008() {
		Logger.start(false,"用券-平台券-券已经使用");
		try {
			
			UseCouponCall usecouponCall1=new  UseCouponCall();
			UseCouponCall usecouponCall2=new  UseCouponCall();
			int userId = TestDataManager.getRandomIntNum(8);
			int orderId = TestDataManager.getRandomIntNum(10);
			CouponShop2cnMCallService CouponShop2cnMCallService = new CouponShop2cnMCallService();
			CreateCouponBean createCouponBean = CouponShop2cnMCallService.setDefaultPlatformCreateCouponBeanForRecieve();
			CreateCouponCall createCouponCall= CouponShop2cnMCallService.createPlatformCoupon(createCouponBean);
			
			UserReceiveCouponCall userReceiveCouponCall = CouponShop2cnMCallService.receiveCouponInfo(createCouponCall.getBatchCode(), userId);

			List<String> CouponCodes=new ArrayList();
			CouponCodes.add(userReceiveCouponCall.getUserReceiveResult().getCouponCode());
			
			couponbatch batch1 = new couponbatchWapper().selectBybatchCode(createCouponCall.getBatchCode()).get(0);
			usecouponBean.setUserId(userId);
			usecouponBean.setMainOrderId(orderId);
			usecouponBean.setCouponCodes(CouponCodes);
			usecouponBean.setAppId("mansit");
			usecouponBean.setRequestId("12344566");
			
			usecouponCall1.setData(usecouponBean);
			usecouponCall1.callService();
			usecouponCall2.setData(usecouponBean);
			usecouponCall2.callService();
			
			Logger.verifyEquals("优惠券已被使用|优惠券已使用", usecouponCall2.getMessage(), "验证返回Message");
			Logger.verifyEquals("21001", usecouponCall2.getStatusCode1(), "验证返回StatusCode");

			Logger.verifyEquals("null", usecouponCall2.getSellerId(), "验证返回sellerId");
	
		} catch (Exception e) {
			Logger.fail(e);
		}
	}
	
	@Test
	@Category({P1.class})
	@TestCase
	public void Tc_UseCoupon_009() {
		Logger.start(false,"用券-商家券-券已经使用");
		try {
			
			UseCouponCall usecouponCall1=new  UseCouponCall();
			UseCouponCall usecouponCall2=new  UseCouponCall();
			
			
			int userId = TestDataManager.getRandomIntNum(8);
			CouponShop2cnMCallService CouponShop2cnMCallService = new CouponShop2cnMCallService();
			
			SellerCreateBatchBean sellerCreateBatchBean = CouponShop2cnMCallService.setDefaultSellerCreateBatchBean();
			SellerCreateBatchCall createCouponCall= CouponShop2cnMCallService.SellerCreateBatch(sellerCreateBatchBean);
		
			UserReceiveCouponCall userReceiveCouponCall = CouponShop2cnMCallService.receiveCouponInfo(createCouponCall.getBatchCode(), userId);

			List<String> CouponCodes=new ArrayList();
			CouponCodes.add(userReceiveCouponCall.getUserReceiveResult().getCouponCode());
			
			couponbatch batch1 = new couponbatchWapper().selectBybatchCode(createCouponCall.getBatchCode()).get(0);
			usecouponBean.setUserId(userId);
			usecouponBean.setMainOrderId(12234);
			usecouponBean.setCouponCodes(CouponCodes);
			usecouponBean.setAppId("mansit");
			usecouponBean.setRequestId("12344566");
			
			usecouponCall1.setData(usecouponBean);
			usecouponCall1.callService();
			usecouponCall2.setData(usecouponBean);
			usecouponCall2.callService();
			
			Logger.verifyEquals("优惠券已被使用|优惠券已使用", usecouponCall2.getMessage(), "验证返回Message");
			Logger.verifyEquals("21001", usecouponCall2.getStatusCode1(), "验证返回StatusCode");
			Logger.verifyEquals("null", usecouponCall2.getSellerId(), "验证返回sellerId");
	
		} catch (Exception e) {
			Logger.fail(e);
		}
	}
	
	@Test
	@Category({P1.class})
	@TestCase
	public void Tc_UseCoupon_010() {
		Logger.start(true,"用券-平台券-团长券-迭代业务");
		try {
			int userId = TestDataManager.getRandomIntNum(8);
			int orderId = TestDataManager.getRandomIntNum(10);
			CouponShop2cnMCallService CouponShop2cnMCallService = new CouponShop2cnMCallService();
			CreateCouponBean createCouponBean = CouponShop2cnMCallService.setDefaultPlatformCreateCouponBeanForRecieve();
			createCouponBean.setIsLimitGroupSponsor(true);//团长劵
			CreateCouponCall createCouponCall= CouponShop2cnMCallService.createPlatformCoupon(createCouponBean);
			
			UserReceiveCouponCall userReceiveCouponCall = CouponShop2cnMCallService.receiveCouponInfo(createCouponCall.getBatchCode(), userId);

			List<String> CouponCodes=new ArrayList();
			CouponCodes.add(userReceiveCouponCall.getUserReceiveResult().getCouponCode());
			
			couponbatch batch1 = new couponbatchWapper().selectBybatchCode(createCouponCall.getBatchCode()).get(0);
			usecouponBean.setUserId(userId);
			usecouponBean.setMainOrderId(orderId);
			usecouponBean.setCouponCodes(CouponCodes);
			usecouponBean.setAppId("mansit");
			usecouponBean.setRequestId("12344566");
			
			usecouponCall.setData(usecouponBean);
			usecouponCall.callService();	
			
			//job处理
			//平台券异步JOB回调更新批次已领取和使用数量，放到Job,目前为了测试方便，直接调用
			new CouponShop2cnMCallService().updatereceivedandusedcount();
			
			Logger.verifyEquals("操作成功！", usecouponCall.getMessage(), "验证返回Message");
			Logger.verifyEquals("0", usecouponCall.getStatusCode1(), "验证返回StatusCode");

			Logger.verifyEquals("null", usecouponCall.getSellerId(), "验证返回sellerId");
			
			couponbatch batch2 = new couponbatchWapper().selectBybatchCode(createCouponCall.getBatchCode()).get(0);

			Logger.verifyEquals(1, batch2.getUsedCount()-batch1.getUsedCount(), "验证数据库couponbatch中UsedCount");
//			Logger.verifyEquals(1, batch1.getTotalNum()-batch2.getTotalNum(), "验证数据库couponbatch中iMaxUseTime");
			
			coupon coupon=new couponWapper().selectByBatchIdAndUserId(batch2.getBatchId(), usecouponBean.getUserId()).get(0);
			
			Logger.verifyEquals(true, coupon.getIsUsed(), "验证数据库coupon中IsUsed");
			for(int i=0;i<usecouponBean.getCouponCodes().size();i++){
			   Logger.verifyEquals(usecouponBean.getCouponCodes().get(i), coupon.getCouponCode(), "验证数据库coupon中第"+i+"条CouponCode");
			}
			Logger.verifyEquals(orderId, Integer.parseInt(coupon.getMainOrderId().toString()), "验证数据库coupon中MainOrderId");
		} catch (Exception e) {
			Logger.fail(e);
		}
	}
	@Test
	@Category({P1.class})
	@TestCase
	public void Tc_UseCoupon_011() {
		Logger.start(true,"用券-平台券-团长券-已使用-迭代业务");
		try {
			UseCouponCall usecouponCall1=new  UseCouponCall();
			UseCouponCall usecouponCall2=new  UseCouponCall();
			
			int userId = TestDataManager.getRandomIntNum(8);
			int orderId = TestDataManager.getRandomIntNum(10);
			CouponShop2cnMCallService CouponShop2cnMCallService = new CouponShop2cnMCallService();
			CreateCouponBean createCouponBean = CouponShop2cnMCallService.setDefaultPlatformCreateCouponBeanForRecieve();
			createCouponBean.setIsLimitGroupSponsor(true);//团长劵
			CreateCouponCall createCouponCall= CouponShop2cnMCallService.createPlatformCoupon(createCouponBean);
			
			UserReceiveCouponCall userReceiveCouponCall = CouponShop2cnMCallService.receiveCouponInfo(createCouponCall.getBatchCode(), userId);

			List<String> CouponCodes=new ArrayList();
			CouponCodes.add(userReceiveCouponCall.getUserReceiveResult().getCouponCode());
			
			couponbatch batch1 = new couponbatchWapper().selectBybatchCode(createCouponCall.getBatchCode()).get(0);
			usecouponBean.setUserId(userId);
			usecouponBean.setMainOrderId(orderId);
			usecouponBean.setCouponCodes(CouponCodes);
			usecouponBean.setAppId("mansit");
			usecouponBean.setRequestId("12344566");
			
			usecouponCall1.setData(usecouponBean);
			usecouponCall1.callService();	
			usecouponCall2.setData(usecouponBean);
			usecouponCall2.callService();
			
			//job处理
			Logger.verifyEquals("优惠券已被使用|优惠券已使用", usecouponCall2.getMessage(), "验证返回Message");
			Logger.verifyEquals("21001", usecouponCall2.getStatusCode1(), "验证返回StatusCode");
			Logger.verifyEquals("null", usecouponCall2.getSellerId(), "验证返回sellerId");
		} catch (Exception e) {
			Logger.fail(e);
		}
	}
}